//
//  JPTitleView.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2020/5/18.
//  Copyright © 2020 zwb. All rights reserved.
//

import UIKit

class JPTitleView: UIView {
    
    lazy var imgbg:UIImageView = {
        var imgbg = UIImageView()
        imgbg.contentMode = .scaleAspectFill
//        imgBtn.imageView?.contentMode = .scaleAspectFit
               imgbg.clipsToBounds = true
        return imgbg
    }()

    lazy var chujiabg:UIView = {
        var timebg = UIView()
        timebg.backgroundColor = #colorLiteral(red: 0.9498772025, green: 0.8849956393, blue: 0.6813783646, alpha: 1)
        return timebg
    }()
    lazy var chujiaLab:UILabel = {
        var lab :UILabel = UILabel()
        lab.font = UIFont.systemFont(ofSize: 15)
        lab.textColor = .red
        lab.text = "状态"
        return lab
    }()
    lazy var titleLab:UILabel = {
        var titleLab :UILabel = UILabel()
        return titleLab
    }()
    lazy var subTitleLab:UILabel = {
        var subTitleLab :UILabel = UILabel()
        subTitleLab.font = UIFont.systemFont(ofSize: 13)
        subTitleLab.textColor = #colorLiteral(red: 0.6000000238, green: 0.6000000238, blue: 0.6000000238, alpha: 1)
        return subTitleLab
    }()
    
    var imgUtil:KSImageSelectUtil!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addSubview(imgbg)
        imgbg.snp.makeConstraints { (make) in
            make.left.top.right.equalTo(self)
            make.height.equalTo(self.snp.width).multipliedBy(0.474)
        }
        
//        imgUtil = KSImageSelectUtil(frame: CGRect(x:0,y:0,width:KSGlobal.screenW,height:KSGlobal.screenW * 0.474),maxImgCount: 1,numberOfRow: 1,picType: .cameraOnly,viewOnly:true)
//            imgUtil.ksDelegate = self
//            addSubview(imgUtil)
//        
        
        
        

        addSubview(titleLab)
        titleLab.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(12)
            make.top.equalTo(imgbg.snp.bottom).offset(5)
        }
        addSubview(subTitleLab)
        addSubview(chujiabg)
        chujiabg.addSubview(chujiaLab)
        
        subTitleLab.snp.makeConstraints { (make) in
            make.left.equalTo(titleLab)
            make.top.equalTo(titleLab.snp.bottom).offset(5)
        }
        
        chujiabg.snp.makeConstraints { (make) in
            make.top.equalTo(subTitleLab.snp.bottom).offset(3)
            make.left.right.equalTo(self)
             make.bottom.equalTo(self)
            make.height.equalTo(35)
        }
        chujiaLab.snp.makeConstraints { (make) in
            make.centerX.centerY.equalTo(chujiabg)
        }
        
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func hiddenChujia() {
        self.chujiabg.isHidden = true
        subTitleLab.snp.remakeConstraints { (make) in
            make.left.equalTo(titleLab)
            make.top.equalTo(titleLab.snp.bottom).offset(5)
            make.bottom.equalTo(self)
        }
    }
    func showChujia() {
        self.chujiabg.isHidden = false
        subTitleLab.snp.remakeConstraints { (make) in
            make.left.equalTo(titleLab)
            make.top.equalTo(titleLab.snp.bottom).offset(5)
        }
    }
    
    
    
}

extension JPTitleView:KSImageUtilDelegate {
    
  
    
    func addImages(_ util: KSImageSelectUtil, imgs: [UIImage]) {
      
        
    }
    
    func deleteImage(_ util: KSImageSelectUtil, index: Int) {
         
    }
    
    
}
